# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=yuview
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.13
pkgrel=1
pkgdesc="YUView is a QT based, cross-platform YUV player with an advanced analytic toolset. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url='http://ient.github.io/YUView/'
license=('GPL3')
depends=("${MINGW_PACKAGE_PREFIX}-qt5-base")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/IENT/YUView/archive/v.${pkgver}.tar.gz")
sha256sums=('24ec418d1138416dce6e615c18896f0c78abe43802c13b5cc5c0085e9904f03f')

prepare() {
  cd "${srcdir}"/YUView-v.${pkgver}
  # Fix version
  sed -e "s|\$\${LASTHASH}|0|g" -i YUViewLib/YUViewLib.pro
  sed -e "s|\$\${SVNN}|${pkgver}|g" -i YUViewLib/YUViewLib.pro
  sed -e "s|\$\${SVNN}|${pkgver}|g" -i YUViewApp/YUViewApp.pro
}

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  cp -r "${srcdir}"/YUView-v.${pkgver} "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ${MINGW_PREFIX}/bin/qmake YUView.pro

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  install -Dm755 YUViewApp/YUView "${pkgdir}${MINGW_PREFIX}/bin/YUView.exe"

  install -Dm644 LICENSE.GPL3 "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
